package edu.gdut.thesissys.vo;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Department entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "department", catalog = "gdutmis")
public class Department extends BaseVo implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 583444291812962184L;
	// Fields

	private Integer departmentId;
	private Institute institute;
	private String name;
	private Set<Major> majors = new HashSet<Major>(0);
	private Set<GradeProportion> gradeProportions = new HashSet<GradeProportion>(
			0);
	private Set<ScoreWeight> scoreWeights = new HashSet<ScoreWeight>(0);
	private Set<Teacher> teachers = new HashSet<Teacher>(0);
	private Set<PaperTitle> paperTitles = new HashSet<PaperTitle>(0);

	// Constructors

	/** default constructor */
	public Department() {
	}

	/** minimal constructor */
	public Department(Institute institute, String name) {
		this.institute = institute;
		this.name = name;
	}

	/** full constructor */
	public Department(Institute institute, String name, Set<Major> majors,
			Set<GradeProportion> gradeProportions,
			Set<ScoreWeight> scoreWeights, Set<Teacher> teachers,
			Set<PaperTitle> paperTitles) {
		this.institute = institute;
		this.name = name;
		this.majors = majors;
		this.gradeProportions = gradeProportions;
		this.scoreWeights = scoreWeights;
		this.teachers = teachers;
		this.paperTitles = paperTitles;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "department_id", unique = true, nullable = false)
	public Integer getDepartmentId() {
		return this.departmentId;
	}

	public void setDepartmentId(Integer departmentId) {
		this.departmentId = departmentId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "institute_id", nullable = false)
	public Institute getInstitute() {
		return this.institute;
	}

	public void setInstitute(Institute institute) {
		this.institute = institute;
	}

	@Column(name = "name", nullable = false, length = 30)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "department")
	public Set<Major> getMajors() {
		return this.majors;
	}

	public void setMajors(Set<Major> majors) {
		this.majors = majors;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "department")
	public Set<GradeProportion> getGradeProportions() {
		return this.gradeProportions;
	}

	public void setGradeProportions(Set<GradeProportion> gradeProportions) {
		this.gradeProportions = gradeProportions;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "department")
	public Set<ScoreWeight> getScoreWeights() {
		return this.scoreWeights;
	}

	public void setScoreWeights(Set<ScoreWeight> scoreWeights) {
		this.scoreWeights = scoreWeights;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "department")
	public Set<Teacher> getTeachers() {
		return this.teachers;
	}

	public void setTeachers(Set<Teacher> teachers) {
		this.teachers = teachers;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "department")
	public Set<PaperTitle> getPaperTitles() {
		return this.paperTitles;
	}

	public void setPaperTitles(Set<PaperTitle> paperTitles) {
		this.paperTitles = paperTitles;
	}

}